package edu.xust.dao.impl;

import edu.xust.config.Repository;
import edu.xust.config.Resource;
import edu.xust.dao.AuditsDao;
import edu.xust.entity.Audits;
import edu.xust.entity.AuditsExample;
import edu.xust.mapper.AuditsMapper;
import edu.xust.page.PageInfo;

import java.util.List;
import java.util.Map;

/**
 * @auther: zhangxin
 * @Description:
 */
@Repository("auditsDao")
public class AuditsDaoImpl implements AuditsDao {

    @Resource
    AuditsMapper auditsMapper;

    @Override
    public List<Audits> selectAuditsByAdidAndByPage(PageInfo pageInfo) {
        Map<String, String> conditions = pageInfo.getConditions();
        String aduId = conditions.get("adid");
        AuditsExample auditsExample = new AuditsExample();
        auditsExample.createCriteria().andAduidEqualTo(Integer.parseInt(aduId));
        long l = auditsMapper.countByExample(null);
        pageInfo.setItemCount((int)l);
        auditsExample.setLimit(pageInfo.getPageSize());
        auditsExample.setOffset(pageInfo.getOffset());
        return auditsMapper.selectAuditsByAdidAndAdmin(auditsExample);
    }
}
